package com.ldq.imooc.basics.io;

import java.io.File;
import java.io.IOException;

/**
 * @Author : 李道泉
 * @Description :
 * @Date : 2018/4/2 17:02
 * @Modified by :
 */
public class FileDemo {

    public static void main(String[] args) {

        File file = new File("F:\\demo.txt");
        if (!file.exists()){
            file.mkdir();
        }else {
            file.delete();
        }
        System.out.println(file.isDirectory());
        System.out.println(file.isFile());

        File file1 = new File("F:\\IO.txt");
        if (!file1.exists()){
            try {
                file1.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }else {
            file1.delete();
        }

        //常用API
        System.out.println(file);
        System.out.println(file.getAbsolutePath());
        System.out.println(file.getName());
        System.out.println(file.getParent());
        System.out.println(file.getAbsoluteFile());
        System.out.println(file.getParentFile().getAbsolutePath());

    }
}
